package com.fizzkai.p2p.core.domain;

import com.fizzkai.p2p.core.util.BitStateUtil;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class UserInfo extends BaseDomain {
    private int version;//乐观锁
    private Long bitState = 0L;//用户状态码

    private String realName;//真实姓名
    private String phoneNumber;//手机号码
    private String email;//邮箱
    private String idNumber;//身份证号码

    private SystemDictionaryItem educationBackground;//学历情况
    private SystemDictionaryItem incomeGrade;//收入情况
    private SystemDictionaryItem houseCondition;//住房情况
    private SystemDictionaryItem marriage;//婚姻情况
    private SystemDictionaryItem kidCount; //子女情况

    private Long realAuthId;    // 实名认证表 ID
    private Long videoAuthId;    // 视频认证表 ID

    public boolean isHasBasicInfo() {
        return BitStateUtil.hasState(bitState, BitStateUtil.HAS_BASICINFO);
    }

    public boolean isHasRealAuth() {
        return BitStateUtil.hasState(bitState, BitStateUtil.HAS_REALAUTH);
    }

    public boolean isHasVideoAuth() {
        return BitStateUtil.hasState(bitState, BitStateUtil.HAS_VIDEOAUTH);
    }

    public boolean isCanBorrow() {
        return isHasBasicInfo() && isHasRealAuth() && isHasVideoAuth();
    }

    public boolean isHasBidRequestProcess() {
        return BitStateUtil.hasState(bitState, BitStateUtil.HAS_BIDREQUEST_PROCESS);
    }

    /**
     * 新增状态
     *
     * @param state 需要新增的状态
     */
    public void addState(Long state) {
        this.bitState = BitStateUtil.addState(this.bitState, state);
    }
    /**
     * 移除
     *
     * @param state 需要新增的状态
     */
    public void removeState(Long state) {
        this.bitState = BitStateUtil.removeState(this.bitState, state);
    }

}
